﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for SanPham
/// </summary>
public class SanPham
{
    AccessData ad = new AccessData();

    public int MaSP { get; set; }
    public int Ma_LoaiSP { get; set; }
    public string Ten_SP { get; set; }
    public string Mo_ta { get; set; }
    public int Gia { get; set; }
    public string Hinh { get; set; }
    public DateTime Ngay_cap_nhat { get; set; }
    public int So_luong { get; set; }
    public bool An_hien { get; set; }
    public void CT(int masp)
    {
        SqlConnection connDB = ad.GetConnect();
        SqlCommand cmd = new SqlCommand("SANPHAM_MaSP", connDB);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add("@Ma_SP", System.Data.SqlDbType.Int).Value = masp;
        SqlDataReader reader;
        connDB.Open();
        reader = cmd.ExecuteReader();
        if (reader.Read())
        {
            Ten_SP = reader["TenSP"].ToString();
            Mo_ta = reader["Mota"].ToString();
            Gia = int.Parse(reader["Gia"].ToString());
            Hinh = reader["Hinhanh"].ToString();
            So_luong = int.Parse(reader["SoLuong"].ToString());
        }
    }

}